<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>换肤</title>
</head>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    body {
        /* display: flex; */
        /* background: url(./img/1.png) no-repeat; */
        text-align: center;
    }

    /* img{
        background: url(./img/1.png) no-repeat;
    } */
    #box {
        width: 100%;
        height: 250px;
        background: rgba(000, 000, 000, 0.2);
        position: absolute;
        top: 0;
        left: 0;
        margin: auto;
    }

    #box img {
        width: 200px;
        height: 200px;
        margin-top: 25px;
    }
</style>

<body>
    <div id="box">
        <img src="./img/1.png" alt="" ondblclick="fn(this)">
        <img src="./img/2.png" alt="" ondblclick="fn(this)">
        <img src="./img/3.jpg" alt="" ondblclick="fn(this)">
        <img src="./img/4.jpg" alt="" ondblclick="fn(this)">
        <img src="./img/5.jpg" alt="" ondblclick="fn(this)">
    </div>
</body>
<script>
    function fn(obj) {
        document.body.style.background = `url(${obj.src}) no-repeat`
        document.body.style.backgroundSize = '100%'
        localStorage.setItem('src', obj.src)
    }
    window.onload = function () {
        document.body.style.background = `url(${localStorage.getItem('src')}) no-repeat`
        document.body.style.backgroundSize = '100%'
    }
</script>

</html>